class Solution:
    def letterCombinations(self, digits: str):
        if not digits:
            return []
        a = {"2": "abc", "3": "def", "4": "ghi", "5": "jkl", "6": "mno", "7": "pqrs", 
             "8":"tuv", "9": "wxyz"}
        s = [""]
        s1=[]
        for i in digits:
            for j in s:
                for b in a[i]:
                    s1.append(j+b)
            s=s1
            s1=[]
        return s


if __name__ == '__main__':
    a = Solution()
    print(a.letterCombinations("23"))
